﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BoCaiWeb.WebSite.Code;
using BoCaiWeb.Model;
using BoCaiWeb.Business;
using System.Collections;
using Ajeelee.Core.Utils;

namespace BoCaiWeb.WebSite.WebAdmin
{
    public partial class LanMuList : AuthPageBase
    {
        protected int pid;
        protected IList<LanMuInfo> lanMuInfoList = new List<LanMuInfo>();
        ILanMuInfoBusiness lanMuInfoBll = new LanMuInfoBusinessFactory().CreateLanMuInfoBusiness();

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                pid = QueryParamInt32("pid");
                // 删除
                if (!string.IsNullOrEmpty(QueryParam("d")) && QueryParamInt32("d") > 0)
                {
                    lanMuInfoBll.Delete(QueryParamInt32("d"));
                    Function.RemoveCacheObject("/cache/parentlanmu/" + pid);
                    System.Threading.Thread.Sleep(500);
                    Page_GoTo(Request.UrlReferrer.AbsoluteUri.IsNotNullAndEmpty() ? Request.UrlReferrer.AbsoluteUri : "LanMuList.aspx");
                }
                if (pid > 0)
                {
                    Hashtable ht = new Hashtable();
                    ht.Add(LanMuInfoHash.PId, pid);
                    ht.Add(LanMuInfoHash.OrderField, "Sort");
                    ht.Add(LanMuInfoHash.OrderDirection, "asc");
                    lanMuInfoList = lanMuInfoBll.GetAllLanMuInfo(ht);
                }
            }
            catch (Exception ex)
            {
                Function.WriteErrorLog(ex);
            }
        }
    }
}